package org.springframework.howelly.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.faces.model.SelectItem;

import org.springframework.stereotype.Service;

@Service
public class ReferenceData {

    private static final String COMPROBANTE = "Comprobante";

    private static final String RECIBO = "Recibo";

    private static final String FACTURA_C = "Factura C";

    private static final String FACTURA_B = "Factura B";

    private static final String FACTURA_A = "Factura A";

    public static final String NOTA_DE_CREDITO = "Nota de credito";

    private static final String Ticket = "Ticket";

    private List<SelectItem> tipoDeGastos;

    private List<SelectItem> tipoDeFacturas;

    private List<SelectItem> creditCardExpMonths;

    private List<SelectItem> ivaRates;

    private List<SelectItem> typesOfExpenses;

    private List<SelectItem> pageSizeOptions;

    public static SimpleDateFormat getSimpleDateFormat() {
	return new SimpleDateFormat("dd/MM/yyyy");
    }

    public List<SelectItem> getTipoDeGastos() {
	if (tipoDeGastos == null) {
	    tipoDeGastos = new ArrayList<SelectItem>();
	    tipoDeGastos.add(new SelectItem("", "Seleccionar una opcion"));
	    tipoDeGastos.add(new SelectItem(Constants.BIENES_DE_USO, Constants.BIENES_DE_USO));
	    tipoDeGastos
		    .add(new SelectItem(Constants.COMBUSTIBLES_Y_LUBRICANTES, Constants.COMBUSTIBLES_Y_LUBRICANTES));
	    tipoDeGastos.add(new SelectItem(Constants.EQUIPOS, Constants.EQUIPOS));
	    tipoDeGastos.add(new SelectItem(Constants.FLETES, Constants.FLETES));
	    tipoDeGastos.add(new SelectItem(Constants.GASTOS_FINANCIEROS, Constants.GASTOS_FINANCIEROS));
	    tipoDeGastos.add(new SelectItem(Constants.GASTOS_GENERALES, Constants.GASTOS_GENERALES));
	    tipoDeGastos.add(new SelectItem(Constants.HONORARIOS_DIRECTORES, Constants.HONORARIOS_DIRECTORES));
	    tipoDeGastos.add(new SelectItem(Constants.IMPUESTOS, Constants.IMPUESTOS));
	    tipoDeGastos.add(new SelectItem(Constants.INSPECCION, Constants.INSPECCION));
	    tipoDeGastos.add(new SelectItem(Constants.MANO_DE_OBRA_PROPIA, Constants.MANO_DE_OBRA_PROPIA));
	    tipoDeGastos.add(new SelectItem(Constants.MATERIALES, Constants.MATERIALES));
	    tipoDeGastos.add(new SelectItem(Constants.MOVILIDADES, Constants.MOVILIDADES));
	    tipoDeGastos.add(new SelectItem(Constants.REPUESTOS_Y_REPARACIONES, Constants.REPUESTOS_Y_REPARACIONES));
	    tipoDeGastos.add(new SelectItem(Constants.SUBCONTRATISTAS, Constants.SUBCONTRATISTAS));
	    tipoDeGastos.add(new SelectItem(Constants.VIATICOS, Constants.VIATICOS));
	}
	return tipoDeGastos;
    }

    public List<SelectItem> getTypesOfExpenses() {
	if (typesOfExpenses == null) {
	    typesOfExpenses = new ArrayList<SelectItem>();
	    typesOfExpenses.add(new SelectItem("", "Todos"));
	    typesOfExpenses.add(new SelectItem(Constants.GASTO, "Gastos"));
	    typesOfExpenses.add(new SelectItem(Constants.INGRESO, "Ingresos"));
	}
	return typesOfExpenses;
    }

    public List<SelectItem> getTipoDeFacturas() {
	if (tipoDeFacturas == null) {
	    tipoDeFacturas = new ArrayList<SelectItem>();
	    tipoDeFacturas.add(new SelectItem("", "Seleccionar una opcion"));
	    tipoDeFacturas.add(new SelectItem(FACTURA_A, FACTURA_A));
	    tipoDeFacturas.add(new SelectItem(FACTURA_B, FACTURA_B));
	    tipoDeFacturas.add(new SelectItem(FACTURA_C, FACTURA_C));
	    tipoDeFacturas.add(new SelectItem(Ticket, Ticket));
	    tipoDeFacturas.add(new SelectItem(RECIBO, RECIBO));
	    tipoDeFacturas.add(new SelectItem(COMPROBANTE, COMPROBANTE));
	    tipoDeFacturas.add(new SelectItem(NOTA_DE_CREDITO, NOTA_DE_CREDITO));

	}

	return tipoDeFacturas;
    }

    public void setTipoDeFacturas(List<SelectItem> tipoDeFacturas) {
	this.tipoDeFacturas = tipoDeFacturas;
    }

    public List<SelectItem> getCreditCardExpMonths() {
	if (creditCardExpMonths == null) {
	    creditCardExpMonths = new ArrayList<SelectItem>();
	    creditCardExpMonths.add(new SelectItem(new Integer(1), "Jan"));
	    creditCardExpMonths.add(new SelectItem(new Integer(2), "Feb"));
	    creditCardExpMonths.add(new SelectItem(new Integer(3), "Mar"));
	    creditCardExpMonths.add(new SelectItem(new Integer(4), "Apr"));
	    creditCardExpMonths.add(new SelectItem(new Integer(5), "May"));
	    creditCardExpMonths.add(new SelectItem(new Integer(6), "Jun"));
	    creditCardExpMonths.add(new SelectItem(new Integer(7), "Jul"));
	    creditCardExpMonths.add(new SelectItem(new Integer(8), "Aug"));
	    creditCardExpMonths.add(new SelectItem(new Integer(9), "Sep"));
	    creditCardExpMonths.add(new SelectItem(new Integer(10), "Oct"));
	    creditCardExpMonths.add(new SelectItem(new Integer(11), "Nov"));
	    creditCardExpMonths.add(new SelectItem(new Integer(12), "Dec"));
	}
	return creditCardExpMonths;
    }

    public List<SelectItem> getIvaRates() {
	if (ivaRates == null) {
	    ivaRates = new ArrayList<SelectItem>();
	    ivaRates.add(new SelectItem("0.21", "21%"));
	    ivaRates.add(new SelectItem("0.18", "18%"));
	    ivaRates.add(new SelectItem("0.105", "10.5"));
	    ivaRates.add(new SelectItem("", "Otro"));

	}
	return ivaRates;
    }

    public List<SelectItem> getPageSizeOptions() {
	if (pageSizeOptions == null) {
	    pageSizeOptions = new ArrayList<SelectItem>();
	    pageSizeOptions.add(new SelectItem(new Integer(5), "5"));
	    pageSizeOptions.add(new SelectItem(new Integer(10), "10"));
	    pageSizeOptions.add(new SelectItem(new Integer(20), "20"));
	}
	return pageSizeOptions;
    }

    public static Date getDateTime() {
	DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
	Date date = new Date();
	String a = dateFormat.format(date);
	try {
	    return dateFormat.parse(a);
	} catch (ParseException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
	return new Date();
    }

}
